package com.github.cosycode.web.base.lang.base;

import com.fasterxml.jackson.annotation.JsonInclude;
import com.github.cosycode.web.base.post.IPostCode;

import java.io.Serializable;

/**
 * <b>Description : </b>
 *
 * @author CPF
 * @date 2019/4/9 10:41
 **/
@JsonInclude(JsonInclude.Include.NON_NULL)
public class PostDto<T> implements Serializable {

    private transient IPostCode postCode = null;

    private T bean = null;

    private String code;

    private String msg;

    private String desc;

    public boolean isSuccess() {
        return IPostCode.isSuccess(code);
    }

    public String getCode() {
        return code;
    }

    public String getMsg() {
        return msg;
    }

    public String getDesc() {
        return desc;
    }

    public void setMsg(String msg) {
        this.msg = msg;
    }

    public void setReturnCode(IPostCode postCode) {
        this.postCode = postCode;
        this.code = postCode.code();
        this.msg = postCode.msg();
        this.desc = postCode.desc();
    }

    public IPostCode getPostCode() {
        return postCode;
    }

    public T getBean() {
        return bean;
    }

    public void setBean(T bean) {
        this.bean = bean;
    }

    @Override
    public String toString() {
        return "PostDto{" + "bean=" + bean + ", code='" + code + '\'' + ", text='" + msg + '\'' + ", desc='" + desc + '\'' + '}';
    }

}
